// $ANTLR 3.1.2 E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g 2013-05-14 20:12:46

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 219
// Unreachable code detected.
#pragma warning disable 162


    using System;
	using System.Reflection;
    using System.Reflection.Emit;
	using System.Diagnostics;
	using System.Linq;

	using Common.Logging;

	using ActorModel.Evolution.SemanticAnalyzing;
	using ActorModel.Evolution.Operations;


using System.Collections.Generic;
using Antlr.Runtime;
using Stack = System.Collections.Generic.Stack<object>;
using List = System.Collections.IList;
using ArrayList = System.Collections.Generic.List<object>;

namespace ActorModel.Evolution.Grammar
{
public partial class EvolutionParser : Parser
{
	internal static readonly string[] tokenNames = new string[] {
		"<invalid>", "<EOR>", "<DOWN>", "<UP>", "AND", "ASSIGN", "BITWISE_AND", "BITWISE_OR", "BOOL_FALSE", "BOOL_TRUE", "COLON", "COMMA", "CONNECTOR_STATE", "DEBUG", "DIV", "EQUALS", "EXCLAMATION_SIGN", "FINALIZE", "FOR", "ID", "IF", "INT", "INTERSECT_OP", "INVERSE", "LEFT_BRACE", "LEFT_BRACKET", "LEFT_PAREN", "LENGTH", "LESS", "LESS_OR_EQUALS", "LINE_COMMENT", "LOG", "MAX", "MIN", "MINUS", "MODULO", "MORE", "MORE_OR_EQUALS", "MULT", "NODE_STATE", "NOT", "NOT_EQUALS", "OCONNECTOR_STATE", "ONODE_STATE", "OR", "PLUS", "RIGHT_BRACE", "RIGHT_BRACKET", "RIGHT_PAREN", "SEMI", "STRING", "SUBSTRING", "TO_NUMBER", "TO_STRING", "TYPE_BOOL", "TYPE_INT", "TYPE_STRING", "UNION_OP", "WHILE", "WS", "XOR"
	};
	public const int EOF=-1;
	public const int AND=4;
	public const int ASSIGN=5;
	public const int BITWISE_AND=6;
	public const int BITWISE_OR=7;
	public const int BOOL_FALSE=8;
	public const int BOOL_TRUE=9;
	public const int COLON=10;
	public const int COMMA=11;
	public const int CONNECTOR_STATE=12;
	public const int DEBUG=13;
	public const int DIV=14;
	public const int EQUALS=15;
	public const int EXCLAMATION_SIGN=16;
	public const int FINALIZE=17;
	public const int FOR=18;
	public const int ID=19;
	public const int IF=20;
	public const int INT=21;
	public const int INTERSECT_OP=22;
	public const int INVERSE=23;
	public const int LEFT_BRACE=24;
	public const int LEFT_BRACKET=25;
	public const int LEFT_PAREN=26;
	public const int LENGTH=27;
	public const int LESS=28;
	public const int LESS_OR_EQUALS=29;
	public const int LINE_COMMENT=30;
	public const int LOG=31;
	public const int MAX=32;
	public const int MIN=33;
	public const int MINUS=34;
	public const int MODULO=35;
	public const int MORE=36;
	public const int MORE_OR_EQUALS=37;
	public const int MULT=38;
	public const int NODE_STATE=39;
	public const int NOT=40;
	public const int NOT_EQUALS=41;
	public const int OCONNECTOR_STATE=42;
	public const int ONODE_STATE=43;
	public const int OR=44;
	public const int PLUS=45;
	public const int RIGHT_BRACE=46;
	public const int RIGHT_BRACKET=47;
	public const int RIGHT_PAREN=48;
	public const int SEMI=49;
	public const int STRING=50;
	public const int SUBSTRING=51;
	public const int TO_NUMBER=52;
	public const int TO_STRING=53;
	public const int TYPE_BOOL=54;
	public const int TYPE_INT=55;
	public const int TYPE_STRING=56;
	public const int UNION_OP=57;
	public const int WHILE=58;
	public const int WS=59;
	public const int XOR=60;

	// delegates
	// delegators

	public EvolutionParser( ITokenStream input )
		: this( input, new RecognizerSharedState() )
	{
	}
	public EvolutionParser( ITokenStream input, RecognizerSharedState state )
		: base( input, state )
	{
	}
		

	public override string[] TokenNames { get { return EvolutionParser.tokenNames; } }
	public override string GrammarFileName { get { return "E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g"; } }


	#region Rules
	protected class evolutionFunction_scope
	{
		public ILGenerator ilGen;
		public ILog log;
		public LocalBuilder statesBuilder;
	}
	partial void evolutionFunction_scopeInit( evolutionFunction_scope scope );partial void evolutionFunction_scopeAfter( evolutionFunction_scope scope );protected Stack<evolutionFunction_scope> evolutionFunction_stack = new Stack<evolutionFunction_scope>();


	// $ANTLR start "evolutionFunction"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:23:0: public evolutionFunction[ILGenerator generator, ILog logger, LocalBuilder states] : block[ReferenceTable.Empty] EOF ;
	public void evolutionFunction( ILGenerator generator, ILog logger, LocalBuilder states )
	{
		evolutionFunction_stack.Push(new evolutionFunction_scope());evolutionFunction_scopeInit(evolutionFunction_stack.Peek());

			((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen = generator;
			((evolutionFunction_scope)evolutionFunction_stack.Peek()).log = logger;
			((evolutionFunction_scope)evolutionFunction_stack.Peek()).statesBuilder = states;

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:37:7: ( block[ReferenceTable.Empty] EOF )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:37:7: block[ReferenceTable.Empty] EOF
			{
			PushFollow(Follow._block_in_evolutionFunction61);
			block(ReferenceTable.Empty);

			state._fsp--;

			Match(input,EOF,Follow._EOF_in_evolutionFunction65); 

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			evolutionFunction_scopeAfter(evolutionFunction_stack.Peek());evolutionFunction_stack.Pop();
		}
		return ;
	}
	// $ANTLR end "evolutionFunction"

	protected class block_scope
	{
		public ReferenceTable inners;
	}
	partial void block_scopeInit( block_scope scope );partial void block_scopeAfter( block_scope scope );protected Stack<block_scope> block_stack = new Stack<block_scope>();


	// $ANTLR start "block"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:39:0: block[ReferenceTable uppers] : ( statement )+ ;
	private void block( ReferenceTable uppers )
	{
		block_stack.Push(new block_scope());block_scopeInit(block_stack.Peek());

			((block_scope)block_stack.Peek()).inners = new ReferenceTable();
			if (uppers != ReferenceTable.Empty)
			{
				((block_scope)block_stack.Peek()).inners.MergeWith(uppers);
			}

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:52:7: ( ( statement )+ )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:52:7: ( statement )+
			{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:52:7: ( statement )+
			int cnt1=0;
			for ( ; ; )
			{
				int alt1=2;
				int LA1_0 = input.LA(1);

				if ( (LA1_0==DEBUG||LA1_0==FINALIZE||(LA1_0>=ID && LA1_0<=IF)||(LA1_0>=OCONNECTOR_STATE && LA1_0<=ONODE_STATE)||(LA1_0>=TYPE_BOOL && LA1_0<=TYPE_STRING)||LA1_0==WHILE) )
				{
					alt1=1;
				}


				switch ( alt1 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:52:0: statement
					{
					PushFollow(Follow._statement_in_block88);
					statement();

					state._fsp--;


					}
					break;

				default:
					if ( cnt1 >= 1 )
						goto loop1;

					EarlyExitException eee1 = new EarlyExitException( 1, input );
					throw eee1;
				}
				cnt1++;
			}
			loop1:
				;



			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			block_scopeAfter(block_stack.Peek());block_stack.Pop();
		}
		return ;
	}
	// $ANTLR end "block"


	// $ANTLR start "statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:54:0: statement : ( if_statement | declaration_statement | assign_statement | while_loop_statement | finalize_statement | debug_statement | assign_outer_connector_state_statement | assign_outer_node_state_statement );
	private void statement(  )
	{
		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:55:7: ( if_statement | declaration_statement | assign_statement | while_loop_statement | finalize_statement | debug_statement | assign_outer_connector_state_statement | assign_outer_node_state_statement )
			int alt2=8;
			switch ( input.LA(1) )
			{
			case IF:
				{
				alt2=1;
				}
				break;
			case TYPE_BOOL:
			case TYPE_INT:
			case TYPE_STRING:
				{
				alt2=2;
				}
				break;
			case ID:
				{
				alt2=3;
				}
				break;
			case WHILE:
				{
				alt2=4;
				}
				break;
			case FINALIZE:
				{
				alt2=5;
				}
				break;
			case DEBUG:
				{
				alt2=6;
				}
				break;
			case OCONNECTOR_STATE:
				{
				alt2=7;
				}
				break;
			case ONODE_STATE:
				{
				alt2=8;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 2, 0, input);

					throw nvae;
				}
			}

			switch ( alt2 )
			{
			case 1:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:55:7: if_statement
				{
				PushFollow(Follow._if_statement_in_statement101);
				if_statement();

				state._fsp--;


				}
				break;
			case 2:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:56:7: declaration_statement
				{
				PushFollow(Follow._declaration_statement_in_statement109);
				declaration_statement();

				state._fsp--;


				}
				break;
			case 3:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:57:7: assign_statement
				{
				PushFollow(Follow._assign_statement_in_statement117);
				assign_statement();

				state._fsp--;


				}
				break;
			case 4:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:58:7: while_loop_statement
				{
				PushFollow(Follow._while_loop_statement_in_statement125);
				while_loop_statement();

				state._fsp--;


				}
				break;
			case 5:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:59:7: finalize_statement
				{
				PushFollow(Follow._finalize_statement_in_statement133);
				finalize_statement();

				state._fsp--;


				}
				break;
			case 6:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:60:4: debug_statement
				{
				PushFollow(Follow._debug_statement_in_statement138);
				debug_statement();

				state._fsp--;


				}
				break;
			case 7:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:61:4: assign_outer_connector_state_statement
				{
				PushFollow(Follow._assign_outer_connector_state_statement_in_statement143);
				assign_outer_connector_state_statement();

				state._fsp--;


				}
				break;
			case 8:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:62:4: assign_outer_node_state_statement
				{
				PushFollow(Follow._assign_outer_node_state_statement_in_statement148);
				assign_outer_node_state_statement();

				state._fsp--;


				}
				break;

			}
		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "statement"


	// $ANTLR start "assign_outer_node_state_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:64:0: assign_outer_node_state_statement : ONODE_STATE ASSIGN exp= expression SEMI ;
	private void assign_outer_node_state_statement(  )
	{
		IToken ONODE_STATE1=null;
		Type exp = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:65:4: ( ONODE_STATE ASSIGN exp= expression SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:65:4: ONODE_STATE ASSIGN exp= expression SEMI
			{
			ONODE_STATE1=(IToken)Match(input,ONODE_STATE,Follow._ONODE_STATE_in_assign_outer_node_state_statement157); 

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldloc, ((evolutionFunction_scope)evolutionFunction_stack.Peek()).statesBuilder);
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldc_I4_0);
				
			Match(input,ASSIGN,Follow._ASSIGN_in_assign_outer_node_state_statement162); 
			PushFollow(Follow._expression_in_assign_outer_node_state_statement168);
			exp=expression();

			state._fsp--;

			Match(input,SEMI,Follow._SEMI_in_assign_outer_node_state_statement170); 

					if (exp != typeof(string))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (ONODE_STATE1!=null?ONODE_STATE1.Line:0), (ONODE_STATE1!=null?ONODE_STATE1.Text:null), typeof(string));
					}
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Stelem_Ref);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "assign_outer_node_state_statement"


	// $ANTLR start "assign_outer_connector_state_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:78:0: assign_outer_connector_state_statement : OCONNECTOR_STATE LEFT_BRACKET pos= expression RIGHT_BRACKET ASSIGN newst= expression SEMI ;
	private void assign_outer_connector_state_statement(  )
	{
		IToken OCONNECTOR_STATE2=null;
		Type pos = default(Type);
		Type newst = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:79:4: ( OCONNECTOR_STATE LEFT_BRACKET pos= expression RIGHT_BRACKET ASSIGN newst= expression SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:79:4: OCONNECTOR_STATE LEFT_BRACKET pos= expression RIGHT_BRACKET ASSIGN newst= expression SEMI
			{
			OCONNECTOR_STATE2=(IToken)Match(input,OCONNECTOR_STATE,Follow._OCONNECTOR_STATE_in_assign_outer_connector_state_statement182); 

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldloc, ((evolutionFunction_scope)evolutionFunction_stack.Peek()).statesBuilder);
				
			Match(input,LEFT_BRACKET,Follow._LEFT_BRACKET_in_assign_outer_connector_state_statement187); 
			PushFollow(Follow._expression_in_assign_outer_connector_state_statement193);
			pos=expression();

			state._fsp--;


					if (pos != typeof(int))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' position part of the expression should be '{2}'-typed", (OCONNECTOR_STATE2!=null?OCONNECTOR_STATE2.Line:0), (OCONNECTOR_STATE2!=null?OCONNECTOR_STATE2.Text:null), typeof(int));
					}

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldc_I4_1);
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Add);
				
			Match(input,RIGHT_BRACKET,Follow._RIGHT_BRACKET_in_assign_outer_connector_state_statement198); 
			Match(input,ASSIGN,Follow._ASSIGN_in_assign_outer_connector_state_statement200); 
			PushFollow(Follow._expression_in_assign_outer_connector_state_statement206);
			newst=expression();

			state._fsp--;

			Match(input,SEMI,Follow._SEMI_in_assign_outer_connector_state_statement208); 

					if (newst != typeof(string))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (OCONNECTOR_STATE2!=null?OCONNECTOR_STATE2.Line:0), (OCONNECTOR_STATE2!=null?OCONNECTOR_STATE2.Text:null), typeof(string));
					}

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Stelem_Ref);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "assign_outer_connector_state_statement"


	// $ANTLR start "debug_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:101:0: debug_statement : DEBUG expression SEMI ;
	private void debug_statement(  )
	{
		Type expression3 = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:102:4: ( DEBUG expression SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:102:4: DEBUG expression SEMI
			{
			Match(input,DEBUG,Follow._DEBUG_in_debug_statement220); 
			PushFollow(Follow._expression_in_debug_statement222);
			expression3=expression();

			state._fsp--;

			Match(input,SEMI,Follow._SEMI_in_debug_statement224); 

					var debug = typeof(Debug).GetMethod("WriteLine", new [] {expression3});
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, debug);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "debug_statement"


	// $ANTLR start "if_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:108:0: if_statement : IF LEFT_PAREN exp= low_priority_expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE ;
	private void if_statement(  )
	{
		IToken IF4=null;
		Type exp = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:109:7: ( IF LEFT_PAREN exp= low_priority_expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:109:7: IF LEFT_PAREN exp= low_priority_expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE
			{
			IF4=(IToken)Match(input,IF,Follow._IF_in_if_statement239); 
			var label = ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.DefineLabel();
			Match(input,LEFT_PAREN,Follow._LEFT_PAREN_in_if_statement245); 
			PushFollow(Follow._low_priority_expression_in_if_statement251);
			exp=low_priority_expression();

			state._fsp--;

			Match(input,RIGHT_PAREN,Follow._RIGHT_PAREN_in_if_statement253); 

					if (exp != typeof(bool) && exp != typeof(int))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' statement should be '{2}'-typed", (IF4!=null?IF4.Line:0), (IF4!=null?IF4.Text:null), typeof(bool));
					}

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Brfalse, label);
				 
			Match(input,LEFT_BRACE,Follow._LEFT_BRACE_in_if_statement259); 
			PushFollow(Follow._block_in_if_statement261);
			block(((block_scope)block_stack.Peek()).inners);

			state._fsp--;

			Match(input,RIGHT_BRACE,Follow._RIGHT_BRACE_in_if_statement265); 

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.MarkLabel(label);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "if_statement"

	protected class assign_statement_scope
	{
		public bool isSubstringAssign;
	}
	partial void assign_statement_scopeInit( assign_statement_scope scope );partial void assign_statement_scopeAfter( assign_statement_scope scope );protected Stack<assign_statement_scope> assign_statement_stack = new Stack<assign_statement_scope>();


	// $ANTLR start "assign_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:123:0: assign_statement : ID ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )? ASSIGN exp= expression SEMI ;
	private void assign_statement(  )
	{
		assign_statement_stack.Push(new assign_statement_scope());assign_statement_scopeInit(assign_statement_stack.Peek());
		IToken ID5=null;
		IToken ASSIGN6=null;
		Type from = default(Type);
		Type to = default(Type);
		Type exp = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:128:7: ( ID ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )? ASSIGN exp= expression SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:128:7: ID ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )? ASSIGN exp= expression SEMI
			{
			ID5=(IToken)Match(input,ID,Follow._ID_in_assign_statement284); 
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:128:10: ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )?
			int alt3=2;
			int LA3_0 = input.LA(1);

			if ( (LA3_0==LEFT_BRACKET) )
			{
				alt3=1;
			}
			switch ( alt3 )
			{
			case 1:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:128:11: LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET
				{
				((assign_statement_scope)assign_statement_stack.Peek()).isSubstringAssign = true;
				Match(input,LEFT_BRACKET,Follow._LEFT_BRACKET_in_assign_statement288); 
				PushFollow(Follow._expression_in_assign_statement294);
				from=expression();

				state._fsp--;

				Match(input,COLON,Follow._COLON_in_assign_statement296); 
				PushFollow(Follow._expression_in_assign_statement302);
				to=expression();

				state._fsp--;

				Match(input,RIGHT_BRACKET,Follow._RIGHT_BRACKET_in_assign_statement304); 

				}
				break;

			}

			ASSIGN6=(IToken)Match(input,ASSIGN,Follow._ASSIGN_in_assign_statement308); 
			PushFollow(Follow._expression_in_assign_statement314);
			exp=expression();

			state._fsp--;

			Match(input,SEMI,Follow._SEMI_in_assign_statement316); 

					if (!((block_scope)block_stack.Peek()).inners.IsDefined((ID5!=null?ID5.Text:null)))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("local variable '{0}' is undefined in this scope yet.", (ID5!=null?ID5.Text:null));
					}

					var localBuilder = ((block_scope)block_stack.Peek()).inners.ResolveBuilder((ID5!=null?ID5.Text:null));
					if (localBuilder.LocalType != exp)
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {2}. Cannot convert type '{0}' to type '{1}'.", localBuilder.LocalType, exp, (ASSIGN6!=null?ASSIGN6.Line:0));
					}

					if (((assign_statement_scope)assign_statement_stack.Peek()).isSubstringAssign)
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldloc, localBuilder);
						var assignSubstringMethod = typeof(Operations.Operations).GetMethod("ReplaceSubstring", new [] {typeof(int), typeof(int), typeof(string), typeof(string)});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, assignSubstringMethod);
					}

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Stloc, localBuilder);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			assign_statement_scopeAfter(assign_statement_stack.Peek());assign_statement_stack.Pop();
		}
		return ;
	}
	// $ANTLR end "assign_statement"


	// $ANTLR start "declaration_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:151:0: declaration_statement : type ID SEMI ;
	private void declaration_statement(  )
	{
		IToken ID7=null;
		Type type8 = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:152:7: ( type ID SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:152:7: type ID SEMI
			{
			PushFollow(Follow._type_in_declaration_statement331);
			type8=type();

			state._fsp--;

			ID7=(IToken)Match(input,ID,Follow._ID_in_declaration_statement333); 
			Match(input,SEMI,Follow._SEMI_in_declaration_statement335); 

					if (((block_scope)block_stack.Peek()).inners.IsDefinedLocal((ID7!=null?ID7.Text:null)))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {1}. Local variable '{0}' is already defined.", (ID7!=null?ID7.Text:null), (ID7!=null?ID7.Line:0));
					}
					
					string id = (ID7!=null?ID7.Text:null);
					var typeVar = type8;
					var localBuilder = ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.DeclareLocal(typeVar);
					((block_scope)block_stack.Peek()).inners.AddLocal(new LocalVariable(id, typeVar, localBuilder));
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "declaration_statement"


	// $ANTLR start "type"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:165:0: type returns [Type returnType] : ( TYPE_INT | TYPE_STRING | TYPE_BOOL );
	private Type type(  )
	{
		Type returnType = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:166:7: ( TYPE_INT | TYPE_STRING | TYPE_BOOL )
			int alt4=3;
			switch ( input.LA(1) )
			{
			case TYPE_INT:
				{
				alt4=1;
				}
				break;
			case TYPE_STRING:
				{
				alt4=2;
				}
				break;
			case TYPE_BOOL:
				{
				alt4=3;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 4, 0, input);

					throw nvae;
				}
			}

			switch ( alt4 )
			{
			case 1:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:166:7: TYPE_INT
				{
				Match(input,TYPE_INT,Follow._TYPE_INT_in_type354); 
				returnType = typeof(int);

				}
				break;
			case 2:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:167:7: TYPE_STRING
				{
				Match(input,TYPE_STRING,Follow._TYPE_STRING_in_type364); 
				returnType = typeof(string);

				}
				break;
			case 3:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:168:4: TYPE_BOOL
				{
				Match(input,TYPE_BOOL,Follow._TYPE_BOOL_in_type371); 
				returnType = typeof(bool);

				}
				break;

			}
		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return returnType;
	}
	// $ANTLR end "type"


	// $ANTLR start "while_loop_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:170:0: while_loop_statement : WHILE LEFT_PAREN exp= expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE ;
	private void while_loop_statement(  )
	{
		IToken WHILE9=null;
		Type exp = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:171:7: ( WHILE LEFT_PAREN exp= expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:171:7: WHILE LEFT_PAREN exp= expression RIGHT_PAREN LEFT_BRACE block[$block::inners] RIGHT_BRACE
			{
			WHILE9=(IToken)Match(input,WHILE,Follow._WHILE_in_while_loop_statement385); 

					var repeat = ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.DefineLabel();
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.MarkLabel(repeat);
				
			Match(input,LEFT_PAREN,Follow._LEFT_PAREN_in_while_loop_statement392); 
			PushFollow(Follow._expression_in_while_loop_statement398);
			exp=expression();

			state._fsp--;

			Match(input,RIGHT_PAREN,Follow._RIGHT_PAREN_in_while_loop_statement400); 

					if (exp != typeof(bool) && exp != typeof(int))
					{
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' statement should be '{2}'-typed", (WHILE9!=null?WHILE9.Line:0), (WHILE9!=null?WHILE9.Text:null), typeof(bool));
					}

					var skipLabel = ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.DefineLabel();
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Brfalse, skipLabel);
				
			Match(input,LEFT_BRACE,Follow._LEFT_BRACE_in_while_loop_statement406); 
			PushFollow(Follow._block_in_while_loop_statement408);
			block(((block_scope)block_stack.Peek()).inners);

			state._fsp--;

			Match(input,RIGHT_BRACE,Follow._RIGHT_BRACE_in_while_loop_statement412); 

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Br, repeat);
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.MarkLabel(skipLabel);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "while_loop_statement"


	// $ANTLR start "finalize_statement"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:192:0: finalize_statement : FINALIZE SEMI ;
	private void finalize_statement(  )
	{
		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:193:7: ( FINALIZE SEMI )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:193:7: FINALIZE SEMI
			{
			Match(input,FINALIZE,Follow._FINALIZE_in_finalize_statement427); 
			Match(input,SEMI,Follow._SEMI_in_finalize_statement429); 

					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldloc, ((evolutionFunction_scope)evolutionFunction_stack.Peek()).statesBuilder);
					((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ret);
				

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return ;
	}
	// $ANTLR end "finalize_statement"


	// $ANTLR start "expression"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:199:0: expression returns [Type returnType] : low_priority_expression ;
	private Type expression(  )
	{
		Type returnType = default(Type);

		Type low_priority_expression10 = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:200:7: ( low_priority_expression )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:200:7: low_priority_expression
			{
			PushFollow(Follow._low_priority_expression_in_expression448);
			low_priority_expression10=low_priority_expression();

			state._fsp--;

			returnType = low_priority_expression10;

			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return returnType;
	}
	// $ANTLR end "expression"

	protected class low_priority_expression_scope
	{
		public string operation;
		public int line;
	}
	partial void low_priority_expression_scopeInit( low_priority_expression_scope scope );partial void low_priority_expression_scopeAfter( low_priority_expression_scope scope );protected Stack<low_priority_expression_scope> low_priority_expression_stack = new Stack<low_priority_expression_scope>();


	// $ANTLR start "low_priority_expression"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:203:0: low_priority_expression returns [Type returnType] : one= lower_middle_priority_expression ( (op= OR |op= AND ) another= lower_middle_priority_expression )* ;
	private Type low_priority_expression(  )
	{
		low_priority_expression_stack.Push(new low_priority_expression_scope());low_priority_expression_scopeInit(low_priority_expression_stack.Peek());
		Type returnType = default(Type);

		IToken op=null;
		Type one = default(Type);
		Type another = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:209:4: (one= lower_middle_priority_expression ( (op= OR |op= AND ) another= lower_middle_priority_expression )* )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:209:4: one= lower_middle_priority_expression ( (op= OR |op= AND ) another= lower_middle_priority_expression )*
			{
			PushFollow(Follow._lower_middle_priority_expression_in_low_priority_expression477);
			one=lower_middle_priority_expression();

			state._fsp--;

			returnType = one;
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:210:11: ( (op= OR |op= AND ) another= lower_middle_priority_expression )*
			for ( ; ; )
			{
				int alt6=2;
				int LA6_0 = input.LA(1);

				if ( (LA6_0==AND||LA6_0==OR) )
				{
					alt6=1;
				}


				switch ( alt6 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:210:12: (op= OR |op= AND ) another= lower_middle_priority_expression
					{
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:210:12: (op= OR |op= AND )
					int alt5=2;
					int LA5_0 = input.LA(1);

					if ( (LA5_0==OR) )
					{
						alt5=1;
					}
					else if ( (LA5_0==AND) )
					{
						alt5=2;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 5, 0, input);

						throw nvae;
					}
					switch ( alt5 )
					{
					case 1:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:210:13: op= OR
						{
						op=(IToken)Match(input,OR,Follow._OR_in_low_priority_expression497); 
						((low_priority_expression_scope)low_priority_expression_stack.Peek()).operation = "Or"; ((low_priority_expression_scope)low_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 2:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:211:13: op= AND
						{
						op=(IToken)Match(input,AND,Follow._AND_in_low_priority_expression517); 
						((low_priority_expression_scope)low_priority_expression_stack.Peek()).operation = "And"; ((low_priority_expression_scope)low_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;

					}

					PushFollow(Follow._lower_middle_priority_expression_in_low_priority_expression528);
					another=lower_middle_priority_expression();

					state._fsp--;


								var mappedOperation = typeof(Operations.Operations).GetMethod(((low_priority_expression_scope)low_priority_expression_stack.Peek()).operation, new [] {one, another});
								if (mappedOperation == null)
								{
									((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. cannot evaluate '{1}' with '{2}' and '{3}'.", ((low_priority_expression_scope)low_priority_expression_stack.Peek()).line, ((low_priority_expression_scope)low_priority_expression_stack.Peek()).operation, one, another);
								}

								((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, mappedOperation);
								returnType = mappedOperation.ReturnType;
							

					}
					break;

				default:
					goto loop6;
				}
			}

			loop6:
				;



			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			low_priority_expression_scopeAfter(low_priority_expression_stack.Peek());low_priority_expression_stack.Pop();
		}
		return returnType;
	}
	// $ANTLR end "low_priority_expression"

	protected class lower_middle_priority_expression_scope
	{
		public string operation;
		public int line;
	}
	partial void lower_middle_priority_expression_scopeInit( lower_middle_priority_expression_scope scope );partial void lower_middle_priority_expression_scopeAfter( lower_middle_priority_expression_scope scope );protected Stack<lower_middle_priority_expression_scope> lower_middle_priority_expression_stack = new Stack<lower_middle_priority_expression_scope>();


	// $ANTLR start "lower_middle_priority_expression"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:225:0: lower_middle_priority_expression returns [Type returnType] : one= middle_priority_expression ( (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING ) another= middle_priority_expression )* ;
	private Type lower_middle_priority_expression(  )
	{
		lower_middle_priority_expression_stack.Push(new lower_middle_priority_expression_scope());lower_middle_priority_expression_scopeInit(lower_middle_priority_expression_stack.Peek());
		Type returnType = default(Type);

		IToken op=null;
		Type one = default(Type);
		Type another = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:231:7: (one= middle_priority_expression ( (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING ) another= middle_priority_expression )* )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:231:7: one= middle_priority_expression ( (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING ) another= middle_priority_expression )*
			{
			PushFollow(Follow._middle_priority_expression_in_lower_middle_priority_expression561);
			one=middle_priority_expression();

			state._fsp--;

			returnType = one;
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:232:2: ( (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING ) another= middle_priority_expression )*
			for ( ; ; )
			{
				int alt8=2;
				int LA8_0 = input.LA(1);

				if ( (LA8_0==EQUALS||(LA8_0>=LESS && LA8_0<=LESS_OR_EQUALS)||(LA8_0>=MORE && LA8_0<=MORE_OR_EQUALS)||LA8_0==NOT_EQUALS||LA8_0==SUBSTRING) )
				{
					alt8=1;
				}


				switch ( alt8 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:232:3: (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING ) another= middle_priority_expression
					{
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:232:3: (op= MORE |op= MORE_OR_EQUALS |op= LESS |op= LESS_OR_EQUALS |op= EQUALS |op= NOT_EQUALS |op= SUBSTRING )
					int alt7=7;
					switch ( input.LA(1) )
					{
					case MORE:
						{
						alt7=1;
						}
						break;
					case MORE_OR_EQUALS:
						{
						alt7=2;
						}
						break;
					case LESS:
						{
						alt7=3;
						}
						break;
					case LESS_OR_EQUALS:
						{
						alt7=4;
						}
						break;
					case EQUALS:
						{
						alt7=5;
						}
						break;
					case NOT_EQUALS:
						{
						alt7=6;
						}
						break;
					case SUBSTRING:
						{
						alt7=7;
						}
						break;
					default:
						{
							NoViableAltException nvae = new NoViableAltException("", 7, 0, input);

							throw nvae;
						}
					}

					switch ( alt7 )
					{
					case 1:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:232:4: op= MORE
						{
						op=(IToken)Match(input,MORE,Follow._MORE_in_lower_middle_priority_expression572); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "More"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 2:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:233:4: op= MORE_OR_EQUALS
						{
						op=(IToken)Match(input,MORE_OR_EQUALS,Follow._MORE_OR_EQUALS_in_lower_middle_priority_expression583); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "MoreOrEquals"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 3:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:234:4: op= LESS
						{
						op=(IToken)Match(input,LESS,Follow._LESS_in_lower_middle_priority_expression594); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "Less"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 4:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:235:4: op= LESS_OR_EQUALS
						{
						op=(IToken)Match(input,LESS_OR_EQUALS,Follow._LESS_OR_EQUALS_in_lower_middle_priority_expression605); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "LessOrEquals"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 5:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:236:4: op= EQUALS
						{
						op=(IToken)Match(input,EQUALS,Follow._EQUALS_in_lower_middle_priority_expression616); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "Equals"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 6:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:237:4: op= NOT_EQUALS
						{
						op=(IToken)Match(input,NOT_EQUALS,Follow._NOT_EQUALS_in_lower_middle_priority_expression627); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "NotEquals"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 7:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:238:4: op= SUBSTRING
						{
						op=(IToken)Match(input,SUBSTRING,Follow._SUBSTRING_in_lower_middle_priority_expression638); 
						((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation = "IsSubstring"; ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;

					}

					PushFollow(Follow._middle_priority_expression_in_lower_middle_priority_expression650);
					another=middle_priority_expression();

					state._fsp--;


							var mappedOperation = typeof(Operations.Operations).GetMethod(((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation, new [] {one, another});
							if (mappedOperation == null)
							{
								((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. cannot evaluate '{1}' with '{2}' and '{3}'.", ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).line, ((lower_middle_priority_expression_scope)lower_middle_priority_expression_stack.Peek()).operation, one, another);
							}

							((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, mappedOperation);
							returnType = mappedOperation.ReturnType;
						

					}
					break;

				default:
					goto loop8;
				}
			}

			loop8:
				;



			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			lower_middle_priority_expression_scopeAfter(lower_middle_priority_expression_stack.Peek());lower_middle_priority_expression_stack.Pop();
		}
		return returnType;
	}
	// $ANTLR end "lower_middle_priority_expression"

	protected class middle_priority_expression_scope
	{
		public string operation;
		public int line;
	}
	partial void middle_priority_expression_scopeInit( middle_priority_expression_scope scope );partial void middle_priority_expression_scopeAfter( middle_priority_expression_scope scope );protected Stack<middle_priority_expression_scope> middle_priority_expression_stack = new Stack<middle_priority_expression_scope>();


	// $ANTLR start "middle_priority_expression"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:253:0: middle_priority_expression returns [Type returnType] : one= high_priority_expression ( (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX ) another= high_priority_expression )* ;
	private Type middle_priority_expression(  )
	{
		middle_priority_expression_stack.Push(new middle_priority_expression_scope());middle_priority_expression_scopeInit(middle_priority_expression_stack.Peek());
		Type returnType = default(Type);

		IToken op=null;
		Type one = default(Type);
		Type another = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:259:7: (one= high_priority_expression ( (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX ) another= high_priority_expression )* )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:259:7: one= high_priority_expression ( (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX ) another= high_priority_expression )*
			{
			PushFollow(Follow._high_priority_expression_in_middle_priority_expression681);
			one=high_priority_expression();

			state._fsp--;

			returnType = one;
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:260:2: ( (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX ) another= high_priority_expression )*
			for ( ; ; )
			{
				int alt10=2;
				int LA10_0 = input.LA(1);

				if ( ((LA10_0>=BITWISE_AND && LA10_0<=BITWISE_OR)||(LA10_0>=MAX && LA10_0<=MODULO)||LA10_0==PLUS||LA10_0==XOR) )
				{
					alt10=1;
				}


				switch ( alt10 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:260:3: (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX ) another= high_priority_expression
					{
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:260:3: (op= PLUS |op= MINUS |op= BITWISE_AND |op= BITWISE_OR |op= XOR |op= MODULO |op= MIN |op= MAX )
					int alt9=8;
					switch ( input.LA(1) )
					{
					case PLUS:
						{
						alt9=1;
						}
						break;
					case MINUS:
						{
						alt9=2;
						}
						break;
					case BITWISE_AND:
						{
						alt9=3;
						}
						break;
					case BITWISE_OR:
						{
						alt9=4;
						}
						break;
					case XOR:
						{
						alt9=5;
						}
						break;
					case MODULO:
						{
						alt9=6;
						}
						break;
					case MIN:
						{
						alt9=7;
						}
						break;
					case MAX:
						{
						alt9=8;
						}
						break;
					default:
						{
							NoViableAltException nvae = new NoViableAltException("", 9, 0, input);

							throw nvae;
						}
					}

					switch ( alt9 )
					{
					case 1:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:260:4: op= PLUS
						{
						op=(IToken)Match(input,PLUS,Follow._PLUS_in_middle_priority_expression692); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Plus"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 2:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:261:4: op= MINUS
						{
						op=(IToken)Match(input,MINUS,Follow._MINUS_in_middle_priority_expression704); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Minus"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 3:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:262:4: op= BITWISE_AND
						{
						op=(IToken)Match(input,BITWISE_AND,Follow._BITWISE_AND_in_middle_priority_expression715); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Intersect"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 4:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:263:4: op= BITWISE_OR
						{
						op=(IToken)Match(input,BITWISE_OR,Follow._BITWISE_OR_in_middle_priority_expression726); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Union"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 5:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:264:4: op= XOR
						{
						op=(IToken)Match(input,XOR,Follow._XOR_in_middle_priority_expression737); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Xor"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 6:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:265:4: op= MODULO
						{
						op=(IToken)Match(input,MODULO,Follow._MODULO_in_middle_priority_expression748); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Modulo"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 7:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:266:4: op= MIN
						{
						op=(IToken)Match(input,MIN,Follow._MIN_in_middle_priority_expression759); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Min"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 8:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:267:4: op= MAX
						{
						op=(IToken)Match(input,MAX,Follow._MAX_in_middle_priority_expression770); 
						((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation = "Max"; ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;

					}

					PushFollow(Follow._high_priority_expression_in_middle_priority_expression782);
					another=high_priority_expression();

					state._fsp--;


							var mappedOperation = typeof(Operations.Operations).GetMethod(((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation, new [] {one, another});
							if (mappedOperation == null)
							{
								((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. cannot evaluate '{1}' with '{2}' and '{3}'.", ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).line, ((middle_priority_expression_scope)middle_priority_expression_stack.Peek()).operation, one, another);
							}

							((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, mappedOperation);
							returnType = mappedOperation.ReturnType;
						

					}
					break;

				default:
					goto loop10;
				}
			}

			loop10:
				;



			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			middle_priority_expression_scopeAfter(middle_priority_expression_stack.Peek());middle_priority_expression_stack.Pop();
		}
		return returnType;
	}
	// $ANTLR end "middle_priority_expression"

	protected class high_priority_expression_scope
	{
		public string operation;
		public int line;
	}
	partial void high_priority_expression_scopeInit( high_priority_expression_scope scope );partial void high_priority_expression_scopeAfter( high_priority_expression_scope scope );protected Stack<high_priority_expression_scope> high_priority_expression_stack = new Stack<high_priority_expression_scope>();


	// $ANTLR start "high_priority_expression"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:282:0: high_priority_expression returns [Type returnType] : one= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* ( (op= MULT |op= DIV ) another= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* )* ;
	private Type high_priority_expression(  )
	{
		high_priority_expression_stack.Push(new high_priority_expression_scope());high_priority_expression_scopeInit(high_priority_expression_stack.Peek());
		Type returnType = default(Type);

		IToken op=null;
		Type one = default(Type);
		Type from = default(Type);
		Type to = default(Type);
		Type another = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:288:7: (one= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* ( (op= MULT |op= DIV ) another= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* )* )
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:288:7: one= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* ( (op= MULT |op= DIV ) another= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* )*
			{
			PushFollow(Follow._atom_in_high_priority_expression813);
			one=atom();

			state._fsp--;

			returnType = one;
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:289:2: ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )*
			for ( ; ; )
			{
				int alt11=2;
				int LA11_0 = input.LA(1);

				if ( (LA11_0==LEFT_BRACKET) )
				{
					alt11=1;
				}


				switch ( alt11 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:289:3: LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET
					{
					Match(input,LEFT_BRACKET,Follow._LEFT_BRACKET_in_high_priority_expression819); 
					PushFollow(Follow._expression_in_high_priority_expression825);
					from=expression();

					state._fsp--;

					Match(input,COLON,Follow._COLON_in_high_priority_expression827); 
					PushFollow(Follow._expression_in_high_priority_expression833);
					to=expression();

					state._fsp--;

					Match(input,RIGHT_BRACKET,Follow._RIGHT_BRACKET_in_high_priority_expression835); 
					var substr = typeof(Operations.Operations).GetMethod("Substring", new [] {one, from, to}); ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, substr);

					}
					break;

				default:
					goto loop11;
				}
			}

			loop11:
				;


			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:290:2: ( (op= MULT |op= DIV ) another= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )* )*
			for ( ; ; )
			{
				int alt14=2;
				int LA14_0 = input.LA(1);

				if ( (LA14_0==DIV||LA14_0==MULT) )
				{
					alt14=1;
				}


				switch ( alt14 )
				{
				case 1:
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:290:3: (op= MULT |op= DIV ) another= atom ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )*
					{
					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:290:3: (op= MULT |op= DIV )
					int alt12=2;
					int LA12_0 = input.LA(1);

					if ( (LA12_0==MULT) )
					{
						alt12=1;
					}
					else if ( (LA12_0==DIV) )
					{
						alt12=2;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 12, 0, input);

						throw nvae;
					}
					switch ( alt12 )
					{
					case 1:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:290:4: op= MULT
						{
						op=(IToken)Match(input,MULT,Follow._MULT_in_high_priority_expression848); 
						((high_priority_expression_scope)high_priority_expression_stack.Peek()).operation = "Multiply"; ((high_priority_expression_scope)high_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;
					case 2:
						// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:291:4: op= DIV
						{
						op=(IToken)Match(input,DIV,Follow._DIV_in_high_priority_expression859); 
						((high_priority_expression_scope)high_priority_expression_stack.Peek()).operation = "Devide"; ((high_priority_expression_scope)high_priority_expression_stack.Peek()).line = (op!=null?op.Line:0);

						}
						break;

					}

					PushFollow(Follow._atom_in_high_priority_expression871);
					another=atom();

					state._fsp--;

					// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:293:17: ( LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET )*
					for ( ; ; )
					{
						int alt13=2;
						int LA13_0 = input.LA(1);

						if ( (LA13_0==LEFT_BRACKET) )
						{
							alt13=1;
						}


						switch ( alt13 )
						{
						case 1:
							// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:293:18: LEFT_BRACKET from= expression COLON to= expression RIGHT_BRACKET
							{
							Match(input,LEFT_BRACKET,Follow._LEFT_BRACKET_in_high_priority_expression874); 
							PushFollow(Follow._expression_in_high_priority_expression880);
							from=expression();

							state._fsp--;

							Match(input,COLON,Follow._COLON_in_high_priority_expression882); 
							PushFollow(Follow._expression_in_high_priority_expression888);
							to=expression();

							state._fsp--;

							Match(input,RIGHT_BRACKET,Follow._RIGHT_BRACKET_in_high_priority_expression890); 
							var substr2 = typeof(Operations.Operations).GetMethod("Substring", new [] {another, from, to}); ((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, substr2);

							}
							break;

						default:
							goto loop13;
						}
					}

					loop13:
						;



							var mappedOperation = typeof(Operations.Operations).GetMethod(((high_priority_expression_scope)high_priority_expression_stack.Peek()).operation, new [] {one, another});
							if (mappedOperation == null)
							{
								((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. cannot evaluate '{1}' with '{2}' and '{3}'.", ((high_priority_expression_scope)high_priority_expression_stack.Peek()).line, ((high_priority_expression_scope)high_priority_expression_stack.Peek()).operation, one, another);
							}

							((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, mappedOperation);
							returnType = mappedOperation.ReturnType;
						

					}
					break;

				default:
					goto loop14;
				}
			}

			loop14:
				;



			}

		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			high_priority_expression_scopeAfter(high_priority_expression_stack.Peek());high_priority_expression_stack.Pop();
		}
		return returnType;
	}
	// $ANTLR end "high_priority_expression"


	// $ANTLR start "atom"
	// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:306:0: atom returns [Type returnType] : ( INT | NODE_STATE | NOT exp= atom | TO_STRING exp= atom | TO_NUMBER exp= atom | INVERSE exp= atom | LENGTH exp= atom | CONNECTOR_STATE LEFT_BRACKET exp= expression RIGHT_BRACKET | ID | STRING | BOOL_TRUE | BOOL_FALSE | LEFT_PAREN expression RIGHT_PAREN );
	private Type atom(  )
	{
		Type returnType = default(Type);

		IToken INT11=null;
		IToken NOT12=null;
		IToken TO_STRING13=null;
		IToken TO_NUMBER14=null;
		IToken INVERSE15=null;
		IToken LENGTH16=null;
		IToken CONNECTOR_STATE17=null;
		IToken ID18=null;
		IToken STRING19=null;
		Type exp = default(Type);
		Type expression20 = default(Type);

		try
		{
			// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:307:7: ( INT | NODE_STATE | NOT exp= atom | TO_STRING exp= atom | TO_NUMBER exp= atom | INVERSE exp= atom | LENGTH exp= atom | CONNECTOR_STATE LEFT_BRACKET exp= expression RIGHT_BRACKET | ID | STRING | BOOL_TRUE | BOOL_FALSE | LEFT_PAREN expression RIGHT_PAREN )
			int alt15=13;
			switch ( input.LA(1) )
			{
			case INT:
				{
				alt15=1;
				}
				break;
			case NODE_STATE:
				{
				alt15=2;
				}
				break;
			case NOT:
				{
				alt15=3;
				}
				break;
			case TO_STRING:
				{
				alt15=4;
				}
				break;
			case TO_NUMBER:
				{
				alt15=5;
				}
				break;
			case INVERSE:
				{
				alt15=6;
				}
				break;
			case LENGTH:
				{
				alt15=7;
				}
				break;
			case CONNECTOR_STATE:
				{
				alt15=8;
				}
				break;
			case ID:
				{
				alt15=9;
				}
				break;
			case STRING:
				{
				alt15=10;
				}
				break;
			case BOOL_TRUE:
				{
				alt15=11;
				}
				break;
			case BOOL_FALSE:
				{
				alt15=12;
				}
				break;
			case LEFT_PAREN:
				{
				alt15=13;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 15, 0, input);

					throw nvae;
				}
			}

			switch ( alt15 )
			{
			case 1:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:307:7: INT
				{
				INT11=(IToken)Match(input,INT,Follow._INT_in_atom917); 

						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldc_I4, int.Parse((INT11!=null?INT11.Text:null)));
						returnType = typeof(int);
					

				}
				break;
			case 2:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:312:4: NODE_STATE
				{
				Match(input,NODE_STATE,Follow._NODE_STATE_in_atom925); 

						//interpreted function contract has 'string nodeState' as 1-st argument
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldarg_0);
						
						returnType = typeof(string);
					

				}
				break;
			case 3:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:319:4: NOT exp= atom
				{
				NOT12=(IToken)Match(input,NOT,Follow._NOT_in_atom933); 
				PushFollow(Follow._atom_in_atom939);
				exp=atom();

				state._fsp--;


						if (exp != typeof(string) && exp != typeof(bool))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed or '{3}'-typed", (NOT12!=null?NOT12.Line:0), (NOT12!=null?NOT12.Text:null), typeof(string), typeof(bool));
						}

						var method = typeof(Operations.Operations).GetMethod("Not", new [] {exp});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, method);
						returnType = method.ReturnType;
					

				}
				break;
			case 4:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:330:4: TO_STRING exp= atom
				{
				TO_STRING13=(IToken)Match(input,TO_STRING,Follow._TO_STRING_in_atom948); 
				PushFollow(Follow._atom_in_atom954);
				exp=atom();

				state._fsp--;


						if (exp != typeof(int))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (TO_STRING13!=null?TO_STRING13.Line:0), (TO_STRING13!=null?TO_STRING13.Text:null), typeof(int));
						}
						
						var method = typeof(Operations.Operations).GetMethod("AsString", new [] {exp});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, method);
						returnType = method.ReturnType;
					

				}
				break;
			case 5:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:341:4: TO_NUMBER exp= atom
				{
				TO_NUMBER14=(IToken)Match(input,TO_NUMBER,Follow._TO_NUMBER_in_atom963); 
				PushFollow(Follow._atom_in_atom969);
				exp=atom();

				state._fsp--;


						if (exp != typeof(string))
						{
							var l = ((evolutionFunction_scope)evolutionFunction_stack.Peek()).log;
							l.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (TO_NUMBER14!=null?TO_NUMBER14.Line:0), (TO_NUMBER14!=null?TO_NUMBER14.Text:null), typeof(string));
						}

						var method = typeof(Operations.Operations).GetMethod("AsNumber", new [] {exp});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, method);
						returnType = method.ReturnType;
					

				}
				break;
			case 6:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:353:4: INVERSE exp= atom
				{
				INVERSE15=(IToken)Match(input,INVERSE,Follow._INVERSE_in_atom978); 
				PushFollow(Follow._atom_in_atom984);
				exp=atom();

				state._fsp--;


						if (exp != typeof(string))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (INVERSE15!=null?INVERSE15.Line:0), (INVERSE15!=null?INVERSE15.Text:null), typeof(string));
						}

						var method = typeof(Operations.Operations).GetMethod("Inverse", new [] {exp});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, method);
						returnType = method.ReturnType;
					

				}
				break;
			case 7:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:364:4: LENGTH exp= atom
				{
				LENGTH16=(IToken)Match(input,LENGTH,Follow._LENGTH_in_atom993); 
				PushFollow(Follow._atom_in_atom999);
				exp=atom();

				state._fsp--;


						if (exp != typeof(string))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (LENGTH16!=null?LENGTH16.Line:0), (LENGTH16!=null?LENGTH16.Text:null), typeof(string));
						}
						
						var method = typeof(Operations.Operations).GetMethod("GetLenth", new [] {exp});
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, method);
						returnType = method.ReturnType;
					

				}
				break;
			case 8:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:375:4: CONNECTOR_STATE LEFT_BRACKET exp= expression RIGHT_BRACKET
				{
				CONNECTOR_STATE17=(IToken)Match(input,CONNECTOR_STATE,Follow._CONNECTOR_STATE_in_atom1007); 

						//interpreted function contract has 'IEnumerable<string> connectorsStates' as 2-d argument
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldarg_1);
					
				Match(input,LEFT_BRACKET,Follow._LEFT_BRACKET_in_atom1015); 
				PushFollow(Follow._expression_in_atom1021);
				exp=expression();

				state._fsp--;

				Match(input,RIGHT_BRACKET,Follow._RIGHT_BRACKET_in_atom1023); 

						if (exp != typeof(int))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {0}. '{1}' expression should be '{2}'-typed", (CONNECTOR_STATE17!=null?CONNECTOR_STATE17.Line:0), (CONNECTOR_STATE17!=null?CONNECTOR_STATE17.Text:null), typeof(int));
						}

						var generic = typeof(Enumerable).GetMethod("ElementAt");
						var constructed = generic.MakeGenericMethod(typeof(string));
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Call, constructed);
						returnType = typeof(string);
					

				}
				break;
			case 9:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:392:7: ID
				{
				ID18=(IToken)Match(input,ID,Follow._ID_in_atom1034); 

						if (!((block_scope)block_stack.Peek()).inners.IsDefined((ID18!=null?ID18.Text:null)))
						{
							((evolutionFunction_scope)evolutionFunction_stack.Peek()).log.ErrorFormat("line: {1}. Local variable '{0}' is undefined in this scope yet", (ID18!=null?ID18.Text:null), (ID18!=null?ID18.Line:0));
						}

						var localBuilder = ((block_scope)block_stack.Peek()).inners.ResolveBuilder((ID18!=null?ID18.Text:null));
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldloc, localBuilder);
						returnType = localBuilder.LocalType;
					

				}
				break;
			case 10:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:403:7: STRING
				{
				STRING19=(IToken)Match(input,STRING,Follow._STRING_in_atom1045); 

						//string should be corrected (remove outer '"' symbols)
						var actualStr = (STRING19!=null?STRING19.Text:null).Substring(1, (STRING19!=null?STRING19.Text:null).Length - 2);
						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldstr, actualStr);
						returnType = typeof(string);
					

				}
				break;
			case 11:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:410:4: BOOL_TRUE
				{
				Match(input,BOOL_TRUE,Follow._BOOL_TRUE_in_atom1053); 

						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldc_I4_1);
						returnType = typeof(bool);
					

				}
				break;
			case 12:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:415:4: BOOL_FALSE
				{
				Match(input,BOOL_FALSE,Follow._BOOL_FALSE_in_atom1061); 

						((evolutionFunction_scope)evolutionFunction_stack.Peek()).ilGen.Emit(OpCodes.Ldc_I4_0);
						returnType = typeof(bool);
					

				}
				break;
			case 13:
				// E:\\Documents\\Projects\\CellularAutomaton\\ActorModel.Evolution\\Grammar\\Evolution.g:420:7: LEFT_PAREN expression RIGHT_PAREN
				{
				Match(input,LEFT_PAREN,Follow._LEFT_PAREN_in_atom1072); 
				PushFollow(Follow._expression_in_atom1074);
				expression20=expression();

				state._fsp--;

				Match(input,RIGHT_PAREN,Follow._RIGHT_PAREN_in_atom1076); 

						returnType = expression20;
					

				}
				break;

			}
		}
		catch ( RecognitionException re )
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
		}
		return returnType;
	}
	// $ANTLR end "atom"
	#endregion Rules


	#region Follow sets
	static class Follow
	{
		public static readonly BitSet _block_in_evolutionFunction61 = new BitSet(new ulong[]{0x0UL});
		public static readonly BitSet _EOF_in_evolutionFunction65 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _statement_in_block88 = new BitSet(new ulong[]{0x5C00C00001A2002UL});
		public static readonly BitSet _if_statement_in_statement101 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _declaration_statement_in_statement109 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _assign_statement_in_statement117 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _while_loop_statement_in_statement125 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _finalize_statement_in_statement133 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _debug_statement_in_statement138 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _assign_outer_connector_state_statement_in_statement143 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _assign_outer_node_state_statement_in_statement148 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _ONODE_STATE_in_assign_outer_node_state_statement157 = new BitSet(new ulong[]{0x20UL});
		public static readonly BitSet _ASSIGN_in_assign_outer_node_state_statement162 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_outer_node_state_statement168 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_assign_outer_node_state_statement170 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _OCONNECTOR_STATE_in_assign_outer_connector_state_statement182 = new BitSet(new ulong[]{0x2000000UL});
		public static readonly BitSet _LEFT_BRACKET_in_assign_outer_connector_state_statement187 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_outer_connector_state_statement193 = new BitSet(new ulong[]{0x800000000000UL});
		public static readonly BitSet _RIGHT_BRACKET_in_assign_outer_connector_state_statement198 = new BitSet(new ulong[]{0x20UL});
		public static readonly BitSet _ASSIGN_in_assign_outer_connector_state_statement200 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_outer_connector_state_statement206 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_assign_outer_connector_state_statement208 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _DEBUG_in_debug_statement220 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_debug_statement222 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_debug_statement224 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _IF_in_if_statement239 = new BitSet(new ulong[]{0x4000000UL});
		public static readonly BitSet _LEFT_PAREN_in_if_statement245 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _low_priority_expression_in_if_statement251 = new BitSet(new ulong[]{0x1000000000000UL});
		public static readonly BitSet _RIGHT_PAREN_in_if_statement253 = new BitSet(new ulong[]{0x1000000UL});
		public static readonly BitSet _LEFT_BRACE_in_if_statement259 = new BitSet(new ulong[]{0x5C00C00001A2000UL});
		public static readonly BitSet _block_in_if_statement261 = new BitSet(new ulong[]{0x400000000000UL});
		public static readonly BitSet _RIGHT_BRACE_in_if_statement265 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _ID_in_assign_statement284 = new BitSet(new ulong[]{0x2000020UL});
		public static readonly BitSet _LEFT_BRACKET_in_assign_statement288 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_statement294 = new BitSet(new ulong[]{0x400UL});
		public static readonly BitSet _COLON_in_assign_statement296 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_statement302 = new BitSet(new ulong[]{0x800000000000UL});
		public static readonly BitSet _RIGHT_BRACKET_in_assign_statement304 = new BitSet(new ulong[]{0x20UL});
		public static readonly BitSet _ASSIGN_in_assign_statement308 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_assign_statement314 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_assign_statement316 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _type_in_declaration_statement331 = new BitSet(new ulong[]{0x80000UL});
		public static readonly BitSet _ID_in_declaration_statement333 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_declaration_statement335 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _TYPE_INT_in_type354 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _TYPE_STRING_in_type364 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _TYPE_BOOL_in_type371 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _WHILE_in_while_loop_statement385 = new BitSet(new ulong[]{0x4000000UL});
		public static readonly BitSet _LEFT_PAREN_in_while_loop_statement392 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_while_loop_statement398 = new BitSet(new ulong[]{0x1000000000000UL});
		public static readonly BitSet _RIGHT_PAREN_in_while_loop_statement400 = new BitSet(new ulong[]{0x1000000UL});
		public static readonly BitSet _LEFT_BRACE_in_while_loop_statement406 = new BitSet(new ulong[]{0x5C00C00001A2000UL});
		public static readonly BitSet _block_in_while_loop_statement408 = new BitSet(new ulong[]{0x400000000000UL});
		public static readonly BitSet _RIGHT_BRACE_in_while_loop_statement412 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _FINALIZE_in_finalize_statement427 = new BitSet(new ulong[]{0x2000000000000UL});
		public static readonly BitSet _SEMI_in_finalize_statement429 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _low_priority_expression_in_expression448 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _lower_middle_priority_expression_in_low_priority_expression477 = new BitSet(new ulong[]{0x100000000012UL});
		public static readonly BitSet _OR_in_low_priority_expression497 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _AND_in_low_priority_expression517 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _lower_middle_priority_expression_in_low_priority_expression528 = new BitSet(new ulong[]{0x100000000012UL});
		public static readonly BitSet _middle_priority_expression_in_lower_middle_priority_expression561 = new BitSet(new ulong[]{0x8023030008002UL});
		public static readonly BitSet _MORE_in_lower_middle_priority_expression572 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _MORE_OR_EQUALS_in_lower_middle_priority_expression583 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _LESS_in_lower_middle_priority_expression594 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _LESS_OR_EQUALS_in_lower_middle_priority_expression605 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _EQUALS_in_lower_middle_priority_expression616 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _NOT_EQUALS_in_lower_middle_priority_expression627 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _SUBSTRING_in_lower_middle_priority_expression638 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _middle_priority_expression_in_lower_middle_priority_expression650 = new BitSet(new ulong[]{0x8023030008002UL});
		public static readonly BitSet _high_priority_expression_in_middle_priority_expression681 = new BitSet(new ulong[]{0x1000200F000000C2UL});
		public static readonly BitSet _PLUS_in_middle_priority_expression692 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _MINUS_in_middle_priority_expression704 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _BITWISE_AND_in_middle_priority_expression715 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _BITWISE_OR_in_middle_priority_expression726 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _XOR_in_middle_priority_expression737 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _MODULO_in_middle_priority_expression748 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _MIN_in_middle_priority_expression759 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _MAX_in_middle_priority_expression770 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _high_priority_expression_in_middle_priority_expression782 = new BitSet(new ulong[]{0x1000200F000000C2UL});
		public static readonly BitSet _atom_in_high_priority_expression813 = new BitSet(new ulong[]{0x4002004002UL});
		public static readonly BitSet _LEFT_BRACKET_in_high_priority_expression819 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_high_priority_expression825 = new BitSet(new ulong[]{0x400UL});
		public static readonly BitSet _COLON_in_high_priority_expression827 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_high_priority_expression833 = new BitSet(new ulong[]{0x800000000000UL});
		public static readonly BitSet _RIGHT_BRACKET_in_high_priority_expression835 = new BitSet(new ulong[]{0x4002004002UL});
		public static readonly BitSet _MULT_in_high_priority_expression848 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _DIV_in_high_priority_expression859 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_high_priority_expression871 = new BitSet(new ulong[]{0x4002004002UL});
		public static readonly BitSet _LEFT_BRACKET_in_high_priority_expression874 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_high_priority_expression880 = new BitSet(new ulong[]{0x400UL});
		public static readonly BitSet _COLON_in_high_priority_expression882 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_high_priority_expression888 = new BitSet(new ulong[]{0x800000000000UL});
		public static readonly BitSet _RIGHT_BRACKET_in_high_priority_expression890 = new BitSet(new ulong[]{0x4002004002UL});
		public static readonly BitSet _INT_in_atom917 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _NODE_STATE_in_atom925 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _NOT_in_atom933 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_atom939 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _TO_STRING_in_atom948 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_atom954 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _TO_NUMBER_in_atom963 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_atom969 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _INVERSE_in_atom978 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_atom984 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _LENGTH_in_atom993 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _atom_in_atom999 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _CONNECTOR_STATE_in_atom1007 = new BitSet(new ulong[]{0x2000000UL});
		public static readonly BitSet _LEFT_BRACKET_in_atom1015 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_atom1021 = new BitSet(new ulong[]{0x800000000000UL});
		public static readonly BitSet _RIGHT_BRACKET_in_atom1023 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _ID_in_atom1034 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _STRING_in_atom1045 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _BOOL_TRUE_in_atom1053 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _BOOL_FALSE_in_atom1061 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _LEFT_PAREN_in_atom1072 = new BitSet(new ulong[]{0x3401800CA81300UL});
		public static readonly BitSet _expression_in_atom1074 = new BitSet(new ulong[]{0x1000000000000UL});
		public static readonly BitSet _RIGHT_PAREN_in_atom1076 = new BitSet(new ulong[]{0x2UL});

	}
	#endregion Follow sets
}

} // namespace ActorModel.Evolution.Grammar
